package com.liveinstars.quhui.business.appconfig.repository.persistence;

import com.liveinstars.quhui.business.appconfig.repository.po.AppVersion;
import com.liveinstars.quhui.business.appconfig.repository.mapper.AppVersionMapper;
import com.liveinstars.quhui.business.appconfig.repository.facade.IAppVersionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ting
 * @since 2020-10-27
 */
@Service
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements IAppVersionService {

    @Override
    public AppVersion findLastVersion(String from, String appCode) {
        List<AppVersion> result = this.baseMapper.findLastVersion(from, appCode);
        if (result != null && result.size() > 0) {
            return result.get(0);
        }
        return null;
    }

    @Override
    public AppVersion findForceUpdateVersion(String from, String appCode) {
        List<AppVersion> result = this.baseMapper.findForceUpdateVersion(from, appCode);
        if (result != null && result.size() > 0) {
            return result.get(0);
        }
        return null;
    }

    @Override
    public AppVersion findNowVersion(String version, String from, String appCode) {
        List<AppVersion> result = this.baseMapper.findNowVersion(version, from, appCode);
        if (result != null && result.size() > 0) {
            return result.get(0);
        }
        return null;
    }
}
